package com.hspedu.newData.LCR;

import com.hspedu.newData.dmsxl.ds.ListNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-17 
 * @Version: 1.0
 */

public class LCR136删除链表的节点 {

    public ListNode deleteNode(ListNode head, int val) {

        ListNode dummy = new ListNode(0,head);
        ListNode cur = head;
        ListNode pre = dummy;

        while (cur.val != val){
            cur = cur.next;
            pre = pre.next;
        }

        pre.next = pre.next.next;

        return dummy.next;
    }
}
